﻿using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CustomSerializer.Tests
{
    [TestClass]
    public class TestSimpleTypes:TestBase
    {
        [TestInitialize]
        public void Init()
        {
            InitSerializer();
        }

        [TestMethod]
        public void SingleObject()
        {
            var o = new SimpleTypes(true);
            TestObject(ser, o);
            TestObject(serCompressed, o);            
        }

        [TestMethod]
        public void SingleObjectProperties() {
            var o = new SimpleTypesProperties(true);
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void Array()
        {
            var o = new object[]
            {
                new SimpleTypes(true),
                new SimpleTypes(),
                new SimpleTypes(true),
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void ArrayProperties()
        {
            var o = new object[]
            {
                new SimpleTypesProperties(true),
                new SimpleTypesProperties(),
                new SimpleTypesProperties(true),
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void ArraySparsed()
        {
            var o = new object[]
            {
                new SimpleTypes(true),
                null,
                new SimpleTypes(true),
                null
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void ArraySparsedProperties()
        {
            var o = new object[]
            {
                new SimpleTypesProperties(true),
                null,
                new SimpleTypesProperties(true),
                null
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableSingleObject()
        {
            var o = new SimpleTypesNullable(true);
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableSingleObjectProperties()
        {
            var o = new SimpleTypesNullablePropertes(true);
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableArray()
        {
            var o = new object[]
            {
                new SimpleTypesNullable(true),
                new SimpleTypesNullable(),
                new SimpleTypesNullable(true),
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableArrayProperties()
        {
            var o = new object[]
            {
                new SimpleTypesNullablePropertes(true),
                new SimpleTypesNullablePropertes(),
                new SimpleTypesNullablePropertes(true),
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableArraySparsed()
        {
            var o = new object[]
            {
                new SimpleTypesNullablePropertes(true),
                null,
                new SimpleTypesNullablePropertes(),
                null
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }

        [TestMethod]
        public void NullableArraySparsedProperties()
        {
            var o = new object[]
            {
                new SimpleTypesNullablePropertes(true),
                null,
                new SimpleTypesNullablePropertes(),
                null
            };
            TestObject(ser, o);
            TestObject(serCompressed, o);
        }
    }
}